<template>
  <div class="mvtop">
    <div class="header">
      <h3 class="title">MV排行榜<i class="el-icon-arrow-right"></i></h3>
      <ul>
        <li
          :style="{ color: item == area ? themeColor : '' }"
          v-for="(item, index) of areaList"
          :key="index"
          @click="onArea(item)"
        >
          {{ item }}
        </li>
      </ul>
    </div>
    <div class="mv-box">
      <div class="top-item" v-for="(item, index) in mvlist" :key="index">
        <p class="index">{{ index + 1 >= 10 ? "" : 0 }}{{ index + 1 }}</p>
        <div class="image" @click="toMvDetails(item.id)">
          <img :src="item.cover" alt="" />
          <div class="mask">
            <span
              ><i class="iconfont icon-huomiao"></i>{{ item.playCount }}</span
            >
          </div>
        </div>
        <div class="name">
          <p :title="item.name" @click="toMvDetails(item.id)">
            {{ item.name }}
          </p>
          <p @click="toSingerDetails(item.artists[0].id)">
            {{ item.artistName }}
          </p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getMvtop } from "@/api/mv";
export default {
  name: "",
  components: {},
  props: {},
  data() {
    return {
      areaList: ["内地", "港台", "欧美", "日本", "韩国"],
      area: "内地",
      mvlist: [] // mv排行榜列表
    };
  },
  computed: {
    themeColor() {
      return this.$store.state.themeColor;
    }
  },
  watch: {},
  created() {
    // 获取mv排行榜
    this.getMvtop();
  },
  mounted() {},
  methods: {
    // 获取mv排行榜
    async getMvtop() {
      const data = await getMvtop({
        area: this.area,
        limit: 10
      });
      this.mvlist = data.data.data;
    },
    onArea(name) {
      this.area = name;
      this.getMvtop();
    },
    toSingerDetails(id) {
      this.$router.push({
        name: "singerdetails",
        query: {
          id
        }
      });
    },
    toMvDetails(id) {
      this.$router.push({
        name: "mvdetails",
        query: {
          id
        }
      });
    }
  }
};
</script>

<style scoped lang="scss">
.mvtop {
  margin-bottom: 6.25rem;
  .header {
    display: flex;
    ul {
      list-style: none;
      display: flex;
      li {
        font-size: 14px;
        width: 60px;
        height: 30px;
        text-align: center;
        line-height: 1.875rem;
        cursor: pointer;
      }
    }
  }
  .title {
    font-size: 1.125rem;
    cursor: pointer;
  }
  .mv-box {
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;

    .top-item {
      width: 50%;
      display: flex;
      justify-content: flex-start;
      align-items: center;
      height: 120px;
      padding: 1.25rem 0;
      .index {
        font-size: 1.125rem;
        color: #ccc;
      }
      .image {
        position: relative;
        width: 200px;
        height: 100%;
        padding: 0 0.625rem;
        img {
          cursor: pointer;
          height: 100%;
          width: 100%;
          border-radius: 5px;
        }
        .mask {
          position: absolute;
          top: 0;
          left: 0;
          padding: 0 0.625rem;
          height: 30px;
          width: 200px;
          border-radius: 5px 0;
          span {
            font-size: 12px;
            float: right;
            color: #fff;
            padding: 0 10px;
            .icon-huomiao {
              font-size: 12px;
            }
          }
        }
      }
      .name {
        p {
          padding: 0.625rem 0;
          cursor: pointer;
          &:nth-child(1) {
            font-size: 14px;
          }
          &:nth-child(2) {
            font-size: 12px;
          }
        }
      }
    }
  }
}
</style>
